
import clear from "rollup-plugin-clear" // 清空文件夹插件
// import { uglify } from "rollup-plugin-uglify" // 输出libary代码压缩
import commonjs from "rollup-plugin-commonjs"
import resolve from "rollup-plugin-node-resolve"
import nodePolyfills from "rollup-plugin-node-polyfills"
import babelPlugin from "rollup-plugin-babel"

const path = require("path")
 
export default {
  input: path.resolve(__dirname, "./src/main.js"),
  output: {
    file: path.resolve(__dirname, "./dist/bundle.js"), // 导出文件
    format: "umd", // 打包文件支持的形式
    name: "MyBundle" // 页面引入时，注入的全局变量
  },
  plugins: [
    clear({
      targets: ['dist']
    }),
    // uglify(),
    commonjs(),
    resolve(),
    nodePolyfills(),
    babelPlugin({
      exclude: "node_modules/**", // 只编译我们的源代码
      runtimeHelpers: true,
    }),
  ]
}